<style src="../../style/statistics.css" scoped></style>
<template>
    <div class="padding10">
        <Row class="divBar">
            <!--搜索框-->
                <Col span="14" >
                    <label  v-show="userInfo.AreaCode=='530000000000'">所属地区:</label>
                    <Select v-model="searchModel.AreaCode" placeholder="全部" :label-in-value="true" @on-change="SearchCascaderChange" style="width:120px" v-show="userInfo.AreaCode=='530000000000'">
                        <Option :value="item.value" v-for="item in AreaList" :key="item.value">{{item.label}}</Option>
                    </Select>                 
                    <span v-show="!lineShow">填报年度:</span>
                    <Select v-model="searchModel.FillInYear" placeholder="全部" :label-in-value="true" @on-change="GetData()" style="width:120px" v-show="!lineShow">
                        <Option :value="item.DictValue" v-for="item in CreateYearList" :key="item.DictValue">{{item.DictText}}</Option>
                    </Select>
                    填报周期：
                    <Select  v-model="searchModel.TimesCycle" placeholder="请选择季别" style="width:100px;" @on-change="GetData()">
                        <Option :value="item.DictValue" v-for="item in QuarterList" :key="item.DictValue">{{item.DictText}}</Option>
                    </Select>
                    <Select  v-model="searchModel.SeasonDict" placeholder="请选择季节值..." style="width:140px;" @on-change="GetData()" v-show="searchModel.TimesCycle==3">
                        <Option value="" >全部</Option>
                        <Option value="小春作" >小春作</Option>
                        <Option value="早春作" >早春作</Option>
                        <Option value="冬作" >冬作</Option>
                    </Select>
                    <Button  type="primary" v-show="listShow" @click="Download()">导出列表</Button> 
                </Col>                      
                <Col span="10"  style="text-align:right;">  
                    <RadioGroup v-model="currentButton" @on-change="changeButton" type="button"  size="large">
                        <Radio label="listShow" title="列表"><Icon type="ios-paper" size="35"></Icon></Radio>                            
                        <Radio label="pieShow" title="饼图"><Icon type="ios-pie" size="35"></Icon></Radio>
                        <Radio label="lineShow" title="折线图"><Icon type="ios-pulse" size="35"></Icon></Radio>
                        <Radio label="mapShow" title="地图"><Icon type="android-map" size="35"></Icon></Radio>                            
                    </RadioGroup>                    
              </Col>                              
        </Row>
        <Row  v-show="listShow">
            <!-- 列表-->
            <div>
                <Table  :columns="columnList" width="100%" no-data-text="暂无数据....." :data="dataList" border :height="clientHeight"></Table>
            </div>
         </Row>
        <Row v-show="pieShow" style="border:1px solid #D7DDE4;overflow:auto">
            <!--饼图-->
            <div v-show="!showNull" id="divPie" ></div>
            <div v-show="showNull" class="NoDataDiv">暂无数据...</div>
        </Row>
        <Row v-show="lineShow" style="border:1px solid #D7DDE4;overflow:auto">
            <!--折线图-->
            <div style="border:1px solid #D7DDE4;padding:10px;margin:5px" >
                <!-- <span style="font-size:18px">指标集合：</span> -->
            <RadioGroup v-model="propIndex" @on-change="propChange()">
                <Radio :label="index" v-for="(item,index) in PropNameList" :key="index">{{item}}</Radio>
            </RadioGroup>
            </div>
            <div  id="divLine" ></div>
        </Row>
        <Row  v-show="mapShow" >
            <!--地图展示-->
            <Tabs type="card" v-show="!showNull">
                <TabPane label="总体概况">
                    <div id="divMapOne" style="border:1px solid #D7DDE4; "></div>
                </TabPane>
                <TabPane label="净作">
                    <div id="divMapTwo" style="border:1px solid #D7DDE4;"></div>
                </TabPane>
                <TabPane label="间作、套种">
                    <div id="divMapThree" style="border:1px solid #D7DDE4; "></div>
                </TabPane>
                <TabPane label="机械化生产">
                    <div id="divMapFour" style="border:1px solid #D7DDE4; "></div>
                </TabPane>
                <TabPane label="亩均收益">
                    <div id="divMapFive" style="border:1px solid #D7DDE4; "></div>
                </TabPane>
            </Tabs>
            <div v-show="showNull" class="NoDataDiv">暂无数据...</div>
        </Row>
    </div>
</template>
<script>
//import echarts from 'echarts';
export default {
    data() {
        return {
            
            showNull:false,//数据为空时显示
            isCounty:false,
            cdataList:[],
            showType:false,
            detailList:[],//详情页列表对象
            currentButton:'listShow',
            listShow:true,//列表显示控制器
            pieShow:false,//饼图显示控制器
            lineShow:false,//柱状图显示控制器
            mapShow:false,//地图显示控制器 
            userInfo: '',
            AreaList: [],//所属行政区划数组,
            TableCodeList: this.GetGroupDict("ReportTableName"),//表名称
            CreateYearList: this.GetGroupDict("ReportYear"),//年度列表列表项为object
            QuarterList: this.GetGroupDict("QuarterCycleValue"), 
            tableStyle:{
                //height:window.innerHeight - 193+'px',
                marginTop:'30px',
                width:'99%'
                },
            DataModel: {//编辑模型
                Id: 0,
                ReportId: '',
                
            },
            //查询模型：根据需求删除不不要查询条件
            searchModel: {
                ReportCode: 'PotSeasonProduct',
                FillInYear: new Date().getFullYear()+"",
                TimesCycle: '3',
                SeasonDict:'',//季别
                AreaCode: this.GetlocaStorage("potUserinfo").AreaCode,
                Status:'',
                PageNumber: 1, PageSize: 20
            },
            dataList:[],
            columnList:[
                {title:'地区',key:'AreaName',align:'center',fixed:'left',width:180},
                {title:'总面积（万亩）',key:'TotalArea',align:'right',width:120,sortable: true},
                {title:'总产量（万吨）',key:'TotalYield',align:'right',width:120,sortable: true},
                {title:'平均亩产（公斤/亩）',key:'AvgMuYield',align:'right',width:120,sortable: true},
                {title:'亩产值（元）',key:'MuOutput',align:'right',width:120,sortable: true},
                {title:'总产值（万元）',key:'TotalOutput',align:'right',width:120,sortable: true},
                {title:'脱毒种薯覆盖面积（万亩）',key:'tdSeedArea',align:'right',width:120,sortable: true},
                {title:'脱毒种薯覆盖率（%）',key:'SeedCoverage',align:'right',width:120,sortable: true},
                {title:'地膜覆盖面积（万亩）',key:'MulchArea',align:'right',width:120,sortable: true},
                {title:'膜下滴灌面积（万亩）',key:'DripArea',align:'right',width:120,sortable: true},
                {title:'配方施肥面积（万亩）',key:'FertilizerArea',align:'right',width:120,sortable: true},
                {title:'免耕栽培面积（万亩）',key:'NoCultivationArea',align:'right',width:120,sortable: true},
                {title:'净作',align:'center',children:[
                    {title:'面积(万亩）',key:'JZArea',align:'right',width:120,sortable: true},
                    {title:'产量（万吨）',key:'JZYield',align:'right',width:120,sortable: true},
                    {title:'平均亩产（公斤/亩）',key:'JZAvgMuYield',align:'right',width:120,sortable: true},
                    {title:'产值（万元）',key:'JZOutput',align:'right',width:120,sortable: true},
                    {title:'亩产值（元）',key:'JZMuOutput',align:'right',width:120,sortable: true},
                    {title:'种植密度（株/亩）',key:'JZDensity',align:'right',width:120,sortable: true},
                ]},
                {title:'间作、套种',align:'center',children:[
                    {title:'面积(万亩）',key:'JTArea',align:'right',width:120,sortable: true},
                    {title:'马铃薯产量（万吨）',key:'JTYield',align:'right',width:120,sortable: true},
                    {title:'马铃薯平均亩产（公斤/亩）',key:'JTAvgMuYield',align:'right',width:120,sortable: true},
                    {title:'复合产量（万吨）',key:'JTMixYield',align:'right',width:120,sortable: true},
                    {title:'复合产值（万元）',key:'JTMixOutput',align:'right',width:120,sortable: true},
                    {title:'复合亩产（公斤/亩）',key:'JTMixMuYield',align:'right',width:120,sortable: true},
                    {title:'复合亩产值（元）',key:'JTMixMuOutput',align:'right',width:120,sortable: true},
                ]},
                {title:'机械化生产',align:'center',children:[
                    {title:'机械播种面积（万亩）',key:'MechPlantArea',align:'right',width:120,sortable: true},
                    {title:'机械田间管理面积（万亩）',align:'center',children:[
                        {title:'其中：中耕培土',key:'MechCultivationArea',align:'right',width:120,sortable: true},
                        {title:'施肥',key:'MechFertilizerArea',align:'right',width:120,sortable: true},
                        {title:'施药',key:'MechPesticideArea',align:'right',width:120,sortable: true}
                    ]},
                    {title:'机械收获面积（万亩）',key:'MechHarvestArea',align:'right',width:120,sortable: true},
                ]},
                {title:'亩均收益',align:'center',children:[
                    {title:'投入（元）',align:'center',children:[
                        {title:'种薯',key:'SeedCost',align:'right',width:120,sortable: true},
                        {title:'肥料',key:'FertilizerCost',align:'right',width:120,sortable: true},
                        {title:'农药',key:'PesticideCost',align:'right',width:120,sortable: true},
                        {title:'地膜',key:'MulchCost',align:'right',width:120,sortable: true},
                        {title:'全生育期用工费',key:'LaborCost',align:'right',width:120,sortable: true},
                        {title:'其他',key:'OtherCost',align:'right',width:120,sortable: true},
                        {title:'投入合计',key:'TotalCost',align:'right',width:120,sortable: true},
                    ]},
                    {title:'产出',align:'center',children:[
                        {title:'平均亩产（公斤/亩）',key:'OAvgMuYield',align:'right',width:120,sortable: true},
                        {title:'平均单价（元/公斤）',key:'OAvgPrice',align:'right',width:120,sortable: true},
                        {title:'产出合计（元）',key:'OTotalOutput',align:'right',width:120,sortable: true},
                    ]},
                    {title:'收益（元）',key:'Income',align:'right',width:120,sortable: true},
                ]},
                {
                    title: '',
                    key: '',
                    align: 'center',
                    width: 50,
                    fixed: 'right'
                }
            ],
            CurrentAreaName:'',
            mapType:'',
            echartsItem0:['总面积（万亩）','总产量（万吨）','平均亩产（公斤/亩）','亩产值（元）','总产值（万元）','脱毒种薯覆盖面积（万亩）','脱毒种薯覆盖率（%）',
                '地膜覆盖面积（万亩）','膜下滴灌面积（万亩）','配方施肥面积（万亩）','免耕栽培面积（万亩）'],
            echartsItem1:['面积(万亩）','产量（万吨）','平均亩产（公斤/亩）','产值（万元）','亩产值（元）','种植密度（株/亩）'],
            echartsItem2:['面积（万亩）','马铃薯产量（万吨）','马铃薯平均亩产（公斤/亩）','复合产量（万吨）','复合产值（万元）',
                '复合亩产（公斤/亩）','复合亩产值（元）'],
            echartsItem3:['机械播种面积（万亩）','中耕培土','施肥','施药','机械收获面积（万亩）'],
            echartsItem4:['种薯（元）','肥料（元）','农药（元）','地膜（元）','全生育期用工费（元）','其他（元）','投入合计（元）',
                '平均单价（元/公斤）','产出合计（元）','收益（元）'],
            GeoData:'',
            //地图数据
            //总体概况
            MapTotalAreaData:[],
            MapTotalYieldData:[],
            MapAvgMuYieldData:[],
            MapMuOutputData:[],
            MapTotalOutputData:[],
            MaptdSeedAreaData:[],
            MapSeedCoverageData:[],
            MapMulchAreaData:[],
            MapDripAreaData:[],
            MapFertilizerAreaData:[],
            MapNoCultivationAreaData:[],
            //净作
            MapJZAreaData:[],
            MapJZYieldData:[],
            MapJZAvgMuYieldData:[],
            MapJZOutputData:[],
            MapJZMuOutputData:[],
            MapJZDensityData:[],
            //间作、套种
            MapJTAreaData:[],
            MapJTYieldData:[],
            MapJTAvgMuYieldData:[],
            MapJTMixYieldData:[],
            MapJTMixOutputData:[],
            MapJTMixMuYieldData:[],
            MapJTMixMuOutputData:[],
            //机械化生产
            MapMechPlantAreaData:[],
            MapMechCultivationAreaData:[],
            MapMechFertilizerAreaData:[],
            MapMechPesticideAreaData:[],
            MapMechHarvestAreaData:[],
            //亩均收益
            MapSeedCostData:[],
            MapFertilizerCostData:[],
            MapPesticideCostData:[],
            MapMulchCostData:[],
            MapLaborCostData:[],
            MapOtherCostData:[],
            MapTotalCostData:[],
            MapOAvgPriceData:[],
            MapOTotalOutputData:[],
            MapIncomeData:[],

            mapList0:[],
            mapList1:[],
            mapList2:[],
            mapList3:[],
            mapList4:[],
            //折线图数据
            propIndex:0,//指标索引
            PropNameList:['总面积（万亩）','总产量（万吨）','平均亩产（公斤/亩）','亩产值（元）','总产值（万元）','脱毒种薯覆盖面积（万亩）','脱毒种薯覆盖率','地膜覆盖面积（万亩）','膜下滴灌面积（万亩）','配方施肥面积（万亩）','免耕栽培面积（万亩）',
            '净作面积（万亩）','净作产量（万吨）','净作平均亩产（公斤/亩）','净作产值（万元）','净作亩产值（元）','净作种植密度（株/亩）',
            '间作、套种面积（万亩）','间作、套种马铃薯产量（万吨）','间作、套种马铃薯平均亩产（公斤/亩）','间作、套种复合产量（万吨）','间作、套种复合产值（万元）','间作、套种复合亩产（公斤/亩）','间作、套种复合亩产值（元）',
            '机械播种面积（万亩）','中耕培土','施肥','施药 ','机械收获面积（万亩）',
            '亩均投入种薯（元）','亩均投入肥料（元）','亩均投入农药（元）','亩均投入地膜（元）','亩均投入全生育期用工费（元）','亩均其他投入（元）','亩均投入合计（元）',
            '平均单价（元/公斤）','产出合计（元）','亩均收益（元）',],//指标名称列表
            PropDataList:[],//指标值列表
            strYearList:[],//年度列表，列表项为string ，作为折线图的x轴数据
            areaLegends:[],//地区作为图例

            clientHeight: window.innerHeight - 200,//表格默认高度
        }
    },
    mounted() {
        //table高度计算方法
        const that = this;
        window.onresize = () => {
            return (() => {
                that.clientHeight = window.innerHeight - 200;
            })()
        };
    },
    methods: {
        SearchAreaList() {
            var areaCode = this.userInfo.AreaCode;
            var areaList=[];
            var templist = [];
            var areaEntity = new Object();
            areaEntity.value=areaCode;
            areaEntity.children=[];
            if (areaCode != '530000000000' && areaCode != null) {
                var item = this.GetlocaStorage("areatreelist")[0];
                areaEntity.label="全州（市）";
                for (var i = 0; i < item.children.length; i++) {
                    if (item.children[i].value == areaCode) {
                        areaList.push(item.children[i]);
                    }
                }
            } else {
                areaEntity.label="全省";
                areaList = this.GetlocaStorage("areatreelist");
            }
            templist.push(areaEntity);
             this.AreaList=templist.concat(areaList[0].children);
        },
        changeButton(n){
            if(n=="listShow")
            {
                this.listShow=true;//显示列表
                this.pieShow=false;
                this.lineShow=false;
                this.mapShow=false;
            }
            else if(n=="pieShow")
            {
                this.listShow=false;
                this.pieShow=true;//显示饼图
                this.lineShow=false;
                this.mapShow=false;
            }
            else if(n=="lineShow")
            {
                this.listShow=false;
                this.pieShow=false;
                this.lineShow=true;//显示饼图
                this.mapShow=false;
                this.showLine();
            }
             else if(n=="mapShow")
            {
                this.listShow=false;
                this.pieShow=false;//显示地图
                this.lineShow=false;//显示地图
                this.mapShow=true;
            }
            else{
                 this.listShow=true;//默认显示列表
                 this.pieShow=false;
                 this.lineShow=false;
                 this.mapShow=false;
            }
        },
        Download(){
            if(this.isCounty){
                window.open(this.$http.defaults.baseURL + "PotSeasonProduct/GetExcelData?FillInYear=" + this.searchModel.FillInYear + "&&AreaCode=" + this.searchModel.AreaCode+"&&TimesCycle=" + this.searchModel.TimesCycle);
            }
            else{
                window.open(this.$http.defaults.baseURL + "PotSeasonProduct/GetStatisExcel?FillInYear="+ this.searchModel.FillInYear 
                + "&&AreaCode=" + this.searchModel.AreaCode+"&&TimesCycle=" + this.searchModel.TimesCycle + "&&SeasonDict="+ this.searchModel.SeasonDict 
                );
            }
          
        },
        // GetData(){
        //   if(this.isCounty){
        //         this.getCountyListData();
        //     }else{
        //         this.getListData();
        //     }
        // },
        rowStyle(index,length){  
            let striprow ={ backgroundColor: '#ebf7ff'};    
            if(index==(length-1)){       
                return {
                    backgroundColor: '#f9c912'
                }
            }
            else if(index%2 !=0){
                return striprow;
            }
             else{
               return 
           }
        },
        rowclass(item,index){
          let striprow ={
            backgroundColor: '#ebf7ff'
          }
          let cityrow = {
             backgroundColor: '#ff6600'
          }
          let provinrow = {
            backgroundColor: '#183'
          }
            if(index %2 ==0){
              if(item.tag==1){
                return cityrow
              }
              else if(item.tag==2){
                return provinrow
              }              
            }
            else{
              if(item.tag==1){
                return cityrow
              }
              else if(item.tag==2){
                return provinrow
              }
              else{
                return striprow
              }
            }
        },
        getStatisListData(){
            var self = this;
            //判断当前用户是否为省级账号
            if(self.userInfo.AreaCode=="530000000000")
            {
                // self.isProvince=true;
                self.mapType=self.searchModel.AreaCode;
            }
            else{
                self.mapType=self.userInfo.AreaCode;
            }
            //地图数据
            //总体概况
            self.MapTotalAreaData=[],
            self.MapTotalYieldData=[],
            self.MapAvgMuYieldData=[],
            self.MapMuOutputData=[],
            self.MapTotalOutputData=[],
            self.MaptdSeedAreaData=[],
            self.MapSeedCoverageData=[],
            self.MapMulchAreaData=[],
            self.MapDripAreaData=[],
            self.MapFertilizerAreaData=[],
            self.MapNoCultivationAreaData=[],
            //净作
            self.MapJZAreaData=[],
            self.MapJZYieldData=[],
            self.MapJZAvgMuYieldData=[],
            self.MapJZOutputData=[],
            self.MapJZMuOutputData=[],
            self.MapJZDensityData=[],
            //间作、套种
            self.MapJTAreaData=[],
            self.MapJTYieldData=[],
            self.MapJTAvgMuYieldData=[],
            self.MapJTMixYieldData=[],
            self.MapJTMixOutputData=[],
            self.MapJTMixMuYieldData=[],
            self.MapJTMixMuOutputData=[],
            //机械化生产
            self.MapMechPlantAreaData=[],
            self.MapMechCultivationAreaData=[],
            self.MapMechFertilizerAreaData=[],
            self.MapMechPesticideAreaData=[],
            self.MapMechHarvestAreaData=[],
            //亩均收益
            self.MapSeedCostData=[],
            self.MapFertilizerCostData=[],
            self.MapPesticideCostData=[],
            self.MapMulchCostData=[],
            self.MapLaborCostData=[],
            self.MapOtherCostData=[],
            self.MapTotalCostData=[],
            self.MapOAvgPriceData=[],
            self.MapOTotalOutputData=[],
            self.MapIncomeData=[],

            self.mapList0=[],
            self.mapList1=[],
            self.mapList2=[],
            self.mapList3=[],
            self.mapList4=[],
            self.GeoData=self.GetGeoData(self.mapType); 
            this.$http.get('PotSeasonProduct/GetStatisListData',{params: this.searchModel}).then(function(res){
                if(res.data.status==1){
                    self.dataList = res.data.model;
                    if(res.data.model==null||res.data.model.length==0)
                    {
                        self.showNull = true
                    }else{
                        self.showNull = false
                        self.CurrentAreaName=res.data.model[res.data.model.length-1].AreaName=="合计"?'云南省':res.data.model[res.data.model.length-1].AreaName;
                        for(var i=0;i<res.data.model.length-1;i++)
                        {
                        //地图数据
                        //总体概况
                        self.MapTotalAreaData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].TotalArea});
                        self.MapTotalYieldData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].TotalYield});
                        self.MapAvgMuYieldData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].AvgMuYield});
                        self.MapMuOutputData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].MuOutput});
                        self.MapTotalOutputData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].TotalOutput});
                        self.MaptdSeedAreaData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].tdSeedArea});
                        self.MapSeedCoverageData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].SeedCoverage});
                        self.MapMulchAreaData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].MulchArea});
                        self.MapDripAreaData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].DripArea});
                        self.MapFertilizerAreaData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].FertilizerArea});
                        self.MapNoCultivationAreaData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].NoCultivationArea});
                        //净作
                        self.MapJZAreaData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].JZArea});
                        self.MapJZYieldData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].JZYield});
                        self.MapJZAvgMuYieldData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].JZAvgMuYield});
                        self.MapJZOutputData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].JZOutput});
                        self.MapJZMuOutputData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].JZMuOutput});
                        self.MapJZDensityData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].JZDensity});
                        //间作、套种
                        self.MapJTAreaData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].JTArea});
                        self.MapJTYieldData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].JTYield});
                        self.MapJTAvgMuYieldData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].JTAvgMuYield});
                        self.MapJTMixYieldData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].JTMixYield});
                        self.MapJTMixOutputData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].JTMixOutput});
                        self.MapJTMixMuYieldData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].JTMixMuYield});
                        self.MapJTMixMuOutputData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].JTMixMuOutput});
                        //机械化生产
                        self.MapMechPlantAreaData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].MechPlantArea});
                        self.MapMechCultivationAreaData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].MechCultivationArea});
                        self.MapMechFertilizerAreaData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].MechFertilizerArea});
                        self.MapMechPesticideAreaData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].MechPesticideArea});
                        self.MapMechHarvestAreaData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].MechHarvestArea});
                        //亩均收益
                        self.MapSeedCostData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].SeedCost});
                        self.MapFertilizerCostData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].FertilizerCost});
                        self.MapPesticideCostData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].PesticideCost});
                        self.MapMulchCostData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].MulchCost});
                        self.MapLaborCostData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].LaborCost});
                        self.MapOtherCostData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].OtherCost});
                        self.MapTotalCostData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].TotalCost});
                        self.MapOAvgPriceData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].OAvgPrice});
                        self.MapOTotalOutputData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].OTotalOutput});
                        self.MapIncomeData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].Income});
                        
                        }
                        
                        //地图数据
                        self.mapList0.push(self.MapTotalAreaData,self.MapTotalYieldData,self.MapAvgMuYieldData,
                            self.MapMuOutputData,self.MapTotalOutputData,self.MaptdSeedAreaData,self.MapSeedCoverageData,
                            self.MapMulchAreaData,self.MapDripAreaData,self.MapFertilizerAreaData,self.MapNoCultivationAreaData);
                        self.mapList1.push(self.MapJZAreaData,self.MapJZYieldData,self.MapJZAvgMuYieldData,
                            self.MapJZOutputData,self.MapJZMuOutputData,self.MapJZDensityData);
                        self.mapList2.push(self.MapJTAreaData,self.MapJTYieldData,self.MapJTAvgMuYieldData,self.MapJTMixYieldData,
                            self.MapJTMixOutputData,self.MapJTMixMuYieldData,self.MapJTMixMuOutputData);
                        self.mapList3.push(self.MapMechPlantAreaData,self.MapMechCultivationAreaData,self.MapMechFertilizerAreaData,
                            self.MapMechPesticideAreaData,self.MapMechHarvestAreaData);
                        self.mapList4.push(self.MapSeedCostData,self.MapFertilizerCostData,self.MapPesticideCostData,
                            self.MapMulchCostData,self.MapLaborCostData,self.MapOtherCostData,self.MapTotalCostData,
                            self.MapOAvgPriceData,self.MapOTotalOutputData,self.MapIncomeData);
                        self.showMap();
                        self.showPie();
                    }
                }else{
                    self.$Modal.error({title:'提示信息',content:res.data.message});
                }
            })
        },
        showMap(){
            var self=this;
            var containerTable=document.getElementsByClassName('ivu-col ivu-col-span-4');
            //******************显示地图
            
            var containerMapOne=document.getElementById('divMapOne');
            var containerMapTwo=document.getElementById('divMapTwo');
            var containerMapThree=document.getElementById('divMapThree');
            var containerMapFour=document.getElementById('divMapFour');
            var containerMapFive=document.getElementById('divMapFive');
            // //用于使chart自适应高度和宽度,通过窗体高宽计算容器高宽
            var resizeContainerMap = function () {
                //containerTable[0].clientWidth 左侧菜单栏的宽度
                containerMapOne.style.width = (window.innerWidth- containerTable[0].clientWidth-80)+'px';
                containerMapOne.style.height = (window.innerHeight-280)+'px';
                containerMapTwo.style.width = (window.innerWidth- containerTable[0].clientWidth-80)+'px';
                containerMapTwo.style.height = (window.innerHeight-280)+'px';
                containerMapThree.style.width = (window.innerWidth- containerTable[0].clientWidth-80)+'px';
                containerMapThree.style.height = (window.innerHeight-280)+'px';
                containerMapFour.style.width = (window.innerWidth- containerTable[0].clientWidth-80)+'px';
                containerMapFour.style.height = (window.innerHeight-280)+'px';
                containerMapFive.style.width = (window.innerWidth- containerTable[0].clientWidth-80)+'px';
                containerMapFive.style.height = (window.innerHeight-280)+'px';
            };
            //设置容器高宽
            resizeContainerMap();

            var myMapOne = myEcharts.init(containerMapOne, 'shine');
            var myMapTwo = myEcharts.init(containerMapTwo, 'shine');
            var myMapThree = myEcharts.init(containerMapThree, 'shine');
            var myMapFour = myEcharts.init(containerMapFour, 'shine');
            var myMapFive = myEcharts.init(containerMapFive, 'shine');
            var MapNameOne=this.searchModel.FillInYear+'年(三)'+self.CurrentAreaName+'马铃薯种薯生产情况统计表';
            var MapNameTwo=this.searchModel.FillInYear+'年(三)'+self.CurrentAreaName+'马铃薯种薯生产情况统计表';
            var MapNameThree=this.searchModel.FillInYear+'年(三)'+self.CurrentAreaName+'马铃薯种薯生产情况统计表';
            var MapNameFour=this.searchModel.FillInYear+'年(三)'+self.CurrentAreaName+'马铃薯种薯生产情况统计表';
            var MapNameFive=this.searchModel.FillInYear+'年(三)'+self.CurrentAreaName+'马铃薯种薯生产情况统计表';
            var optionMapOne = self.GetMapOption(MapNameOne,self.GeoData,self.mapType,self.echartsItem0,self.mapList0);
            var optionMapTwo = self.GetMapOption(MapNameTwo,self.GeoData,self.mapType,self.echartsItem1,self.mapList1);
            var optionMapThree = self.GetMapOption(MapNameThree,self.GeoData,self.mapType,self.echartsItem2,self.mapList2);
            var optionMapFour = self.GetMapOption(MapNameFour,self.GeoData,self.mapType,self.echartsItem3,self.mapList3);
            var optionMapFive = self.GetMapOption(MapNameFive,self.GeoData,self.mapType,self.echartsItem4,self.mapList4);
            myMapOne.setOption(optionMapOne);
            myMapTwo.setOption(optionMapTwo);
            myMapThree.setOption(optionMapThree);
            myMapFour.setOption(optionMapFour);
            myMapFive.setOption(optionMapFive);
            //用于使chart自适应高度和宽度
            window.onresize = function () {
                //重置容器高宽
                resizeContainerMap();
                myMapOne.resize();
                myMapTwo.resize();
                myMapThree.resize();
                myMapFour.resize();
                myMapFive.resize();
            };
        },
        getCountyListData(){
            var self = this;
            this.$http.get("PotSeasonProduct", { params: { AreaCode: this.searchModel.AreaCode,FillInYear:this.searchModel.FillInYear,TimesCycle:this.searchModel.TimesCycle } }).then(
                function (res) {
                    if (res.data.status == 1) {
                        self.cdataList = res.data.model; 
                    }
                    else{
                        self.$Modal.error({title:'提示信息',content:res.data.message});
                    }   
                    
            });
        },
        currentYear() {
           let year = new Date().getFullYear();
           let month = new Date().getMonth();
            if (month > 1) {
                this.searchModel.FillInYear = year.toString();
            } else {
               this.searchModel.FillInYear = (year - 1).toString();
              }
        },
        // SearchCascaderChange(value, selectedData) {
        //     const index = value.length - 1;
        //     this.searchModel.AreaCode = value[index];
        //     if(this.searchModel.AreaCode.substr(4,2) !="00"){
        //         this.isCounty = true;
        //     }
        //     else{
        //         this.isCounty = false;
        //     }
        //     this.GetData();
        // },
        SearchCascaderChange() {
            if(this.searchModel.AreaCode.substr(4,2) !="00"){
                this.isCounty = true;
            }
            else{
                this.isCounty = false;
            }
            this.GetData();
        },
        showPie(){
            var containerPie=document.getElementById('divPie');
            var containerTable=document.getElementsByClassName('ivu-col ivu-col-span-4');
            containerPie.style.width = (window.innerWidth- containerTable[0].clientWidth-22)+'px';
            containerPie.style.height = (window.innerHeight-280)+'px';
            var myChart = myEcharts.init(document.getElementById('divPie'), 'shine');
            var option = {
                title:{show:true,text:'马铃薯面积-产量-产值统计',left: 'center'},
                tooltip : {
                    // trigger: 'item',
                    formatter: "{a} <br/>{b} : {c} ({d}%)"
                },
                series: [{
                    type: 'pie',
                    name:'面积',
                    radius: 90,
                    center: ['15%', '50%'],
                    data:this.MapTotalAreaData
                },
                {
                    type: 'pie',
                    name:'产量',
                    radius: 90,
                    center: ['50%', '50%'],
                    data:this.MapTotalYieldData
                },
                {
                    type: 'pie',
                    name:'产值',
                    radius: 90,
                    center: ['85%', '50%'],
                    data:this.MapTotalOutputData
                }
                ]
            };
            
            myChart.setOption(option);
        },
        showLine(){
            console.log(this.MapTotalAreaData)
            var containerLine=document.getElementById('divLine');
            var containerTable=document.getElementsByClassName('ivu-col ivu-col-span-4');
            containerLine.style.width = (window.innerWidth- containerTable[0].clientWidth-42)+'px';
            containerLine.style.height = (window.innerHeight-320)+'px';
            var myChart = myEcharts.init(document.getElementById('divLine'), 'shine');
            var lineOption = this.getLineOption(this.PropDataList,this.propIndex,this.PropNameList[this.propIndex]);
            
            myChart.setOption(lineOption);
        },
        propChange(){
            this.showLine();
        },
        getAllYearStatisList(){
            var self = this;
            this.$http.get('PotSeasonProduct/GetAllYearStatisList',{params: this.searchModel}).then(function(res){
                if(res.data.status==1){
                    self.PropDataList = res.data.model;
                }
                else{
                    self.$Modal.error({title:'提示信息',content:res.data.message});
                }
            });
        },
        GetData(){
            this.getStatisListData();
            this.getAllYearStatisList();
        }
    },
    //创建Vue页面方法
    created: function () {
       // this.currentYear();
       //this.SearchAreaList();
       this.userInfo = this.GetlocaStorage("potUserinfo");
       this.AreaList = this.getChildAreaList(this.userInfo.AreaCode);
       this.GetData();
    },
    watch: {
        //需要监听的在此处新增监听对象
    }
}
</script>
